package bug
{
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	import br.com.stimuli.loading.BulkLoader;
	import br.com.stimuli.loading.BulkProgressEvent;

	public class Main extends Sprite
	{
		public static var staticData:StaticData;//业务数据.
		private var _battle:bugTest;
		public function Main()
		{
			load();
		}
		
		private function load():void{ 
			staticData=new StaticData();
			var t:BulkLoader = new BulkLoader("data_load");
			t.add("data/level.xml",{id:"level"});
			t.add("data/buff.xml",{id:"buff"});
			t.addEventListener(BulkProgressEvent.COMPLETE , onFileComleted,false,0,true);
			t.start();
		}
		private  var level:LevelPanal
		private function onFileComleted(e:BulkProgressEvent):void{
			var x:XML = e.currentTarget.getXML("buff")
			staticData.push("buff",x);
			staticData.push("level",e.currentTarget.getXML("level"));
			//start();
			 level = new LevelPanal();
			addChild(level);
			
			this.addEventListener(MouseEvent.CLICK,onClick);
			
		}
		private function onClick(e:MouseEvent):void{
			var str:String = e.target.name;
			if(str.indexOf("btlevel")>=0){
				start(int( str.slice(7)));
				level.parent.removeChild(level);
			}
			
		}
		private function start(level:int):void{
			if(_battle==null){
				_battle = new bugTest();
			}
			_battle.start(level);
			addChild(_battle);
		}
	}
}